package ui;

/**
 * JPanel EmployeeLogin
 * 
 * @author XA9
 * 
 */


import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.ImageIcon;
import java.util.Date;

public class EmployeeLogin extends JPanel {
	private JLabel lblPleaseEnter;
	private JLabel lblWelcomeEmployee;
	private JLabel lblLoginId;
	private JPasswordField pfPassword;
	private JLabel lblPassword;
	private JButton btnLogin;
	private JLabel lblXA9;
	private JTextField tfLoginId;
	private JLabel lblUserIcon;
	private JLabel lblLogo;
	
	/**
	 * Create the panel.
	 */
	public EmployeeLogin() {
		setBackground(UIManager.getColor("Label.background"));
		setLayout(null);

		lblWelcomeEmployee = new JLabel("Welcome Employee!");
		lblWelcomeEmployee.setOpaque(true);
		lblWelcomeEmployee
				.setBackground(UIManager.getColor("Label.background"));
		lblWelcomeEmployee.setHorizontalAlignment(SwingConstants.CENTER);
		lblWelcomeEmployee.setForeground(Color.BLACK);
		lblWelcomeEmployee.setFont(new Font("Eurostile", Font.BOLD, 24));
		lblWelcomeEmployee.setBounds(0, 124, 735, 28);
		add(lblWelcomeEmployee);

		lblPleaseEnter = new JLabel(
				"Please enter login details to enter system");
		lblPleaseEnter.setHorizontalAlignment(SwingConstants.CENTER);
		lblPleaseEnter.setForeground(Color.BLACK);
		lblPleaseEnter.setFont(new Font("Eurostile", Font.PLAIN, 16));
		lblPleaseEnter.setBounds(0, 158, 735, 16);
		add(lblPleaseEnter);

		lblLoginId = new JLabel("LoginId:");
		lblLoginId.setFont(new Font("Eurostile", Font.PLAIN | Font.BOLD, 13));
		lblLoginId.setBounds(354, 186, 200, 28);
		add(lblLoginId);

		lblPassword = new JLabel("Password:");
		lblPassword.setFont(new Font("Eurostile", Font.PLAIN | Font.BOLD, 13));
		lblPassword.setBounds(354, 235, 200, 28);
		add(lblPassword);

		btnLogin = new JButton("Login");
		btnLogin.setFont(new Font("Eurostile", Font.BOLD, 13));
		btnLogin.setBounds(349, 297, 155, 35);
		add(btnLogin);

		lblXA9 = new JLabel("\u00A92013 CBS HA.IT (Gruppe XA-9)\t\t ");
		lblXA9.setForeground(UIManager.getColor("Button.darkShadow"));
		lblXA9.setBackground(UIManager.getColor("Button.darkShadow"));
		lblXA9.setHorizontalAlignment(SwingConstants.CENTER);
		lblXA9.setFont(new Font("Eurostile", Font.PLAIN, 11));
		lblXA9.setBounds(0, 550, 735, 50);
		add(lblXA9);

		pfPassword = new JPasswordField();
		pfPassword.setForeground(UIManager
				.getColor("PasswordField.inactiveForeground"));
		pfPassword.setBounds(349, 257, 155, 35);
		add(pfPassword);
		pfPassword.setColumns(10);

		tfLoginId = new JTextField();
		tfLoginId.setFont(new Font("Eurostile", Font.PLAIN, 13));
		tfLoginId.setForeground(UIManager
				.getColor("PasswordField.inactiveForeground"));
		tfLoginId.setBounds(349, 208, 155, 35);
		add(tfLoginId);
		tfLoginId.setColumns(10);

		lblUserIcon = new JLabel("");
		lblUserIcon.setIcon(new ImageIcon(
				"/Users/martinotto-sidelmann/Desktop/user.png"));
		lblUserIcon.setBounds(180, 146, 236, 264);
		add(lblUserIcon);

		lblLogo = new JLabel("");
		lblLogo.setIcon(new ImageIcon(
				"/Users/martinotto-sidelmann/Desktop/Zombium.png"));
		lblLogo.setBounds(530, 12, 200, 70);
		add(lblLogo);

	}

	/**
	 * Parse value of JTextfield tfLoginId as integer
	 * 
	 * @return int loginid
	 */
	public int getLoginIdEmployee() {
		try {
			return Integer.parseInt(tfLoginId.getText().trim());
		} catch (NumberFormatException e) {
			return -1;
		}

	}

	/**
	 * Parse value of JTextfield tfPassword as integer
	 * 
	 * @return int password
	 */
	public int getPasswordEmployee() {
		try {
			return Integer.parseInt(pfPassword.getText().trim());
		} catch (NumberFormatException e) {
			return -1;
		}

	}

	/**
	 * Returns JButton
	 * 
	 * @return btnLogin
	 */
	public JButton getBtnLogin() {
		return btnLogin;
	}

	/**
	 * Clear fields of JTextfields
	 * 
	 */
	public void clearFields() {
		pfPassword.setText("");
		tfLoginId.setText("");
	}

	/**
	 * Add ActionListener to JButtons
	 * 
	 * @param ActionListener l
	 * 
	 */
	public void addActionListener(ActionListener l) {
		btnLogin.addActionListener(l);
		pfPassword.addActionListener(l);
		tfLoginId.addActionListener(l);
	}
}
